﻿#ifndef DIALOG_H
#define DIALOG_H

#include "itembaseeditor.h"
#include <QSystemTrayIcon>

#include "itemadd.h"
#include "itemedit.h"
#include "itemview.h"

#define TD_ITEM "quick_reply"
#define TD_TRACE "quick_reply_trace"
#define FLUSH_TIME 900  //15分钟

namespace Ui {
class Dialog;
}

class Dialog : public ItemBaseEditor
{
    Q_OBJECT

public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();

    void createTray();
    void updateView();
    void generateMenu();

    void newItem();
    void editItem();
    void removeItem();
    void collapseAll();
    void flushSpoor();
    void showItemView(const QString &label, const QString &detail);
    void detectOpenView();

protected:
    void timerEvent(QTimerEvent *event);

protected slots:
    void trayActivated(QSystemTrayIcon::ActivationReason);

private slots:
    void on_treeView_clicked(const QModelIndex &index);
    void on_treeView_doubleClicked(const QModelIndex &index);
    void on_input_returnPressed();

private:
    Ui::Dialog *ui;
    QSystemTrayIcon *tray;
    QMenu *tray_Menu;

    ItemView *view;

    int cleanTimer;
    int flushTimer;
    bool openViewFlag;
    QString hostName;
    QMap<QString,int> spoor;
};

#endif // DIALOG_H
